import { defineStore } from "pinia";

export const useOperationRecordStore = defineStore("operationRecord", {
  state: () => ({
    records: {}, // 用于保存按 fileID 分类的 operation_record
  }),
  getters: {
    hasOperationRecord: (state) => (fileID) => !!state.records[fileID], // 判断是否已有记录
    getOperationRecord: (state) => (fileID) => state.records[fileID], // 获取当前的记录
  },
  actions: {
    setOperationRecord(fileID, record) {
      this.records[fileID] = record; // 根据 fileID 设置 operation_record
    },
    clearOperationRecord(fileID) {
      delete this.records[fileID]; // 根据 fileID 清空记录
    },
  },
});
